package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CheckGroupDao {
    //@Insert("insert into t_checkgroup values (#{id},#{code},#{name},#{helpCode},#{sex},#{remark},#{attention},)")
    void addCheckGroup(CheckGroup checkGroup);
    @Insert("insert into t_checkgroup_checkitem VALUES (#{CheckGroupId},#{CheckItemId})")
    void addCheckGroup_CheckItem(@Param("CheckGroupId") Integer CheckGroupId,@Param("CheckItemId") Integer CheckItemId);
    //CheckGroupDao.xml
    Page<CheckGroup> findPage(String condition);
    @Select("select * from t_checkgroup where id = #{id}")
    CheckGroup findById(Integer id);
    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id}")
    List<Integer> findCheckItemIdsByCheckGroupId(Integer id);
    //CheckGroupDao.xml
    void update(CheckGroup checkGroup);
    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{checkGroupId}")
    void deletet_checkgroup_checkitemBycheckGroup_id(Integer checkGroupId);
    @Select("select count(1) from t_setmeal_checkgroup where checkgroup_id =#{checkGroupId}")
    Long findt_etmeal_checkgroupCountBycheckgroup_id(Integer checkGroupId);
    @Delete("delete from  t_checkgroup where id = #{id}")
    void deletet_checkgroupById(Integer id);
}
